

var canCompleteCircuit = function(gas, cost){

    for(var i = 0; i < gas.length; i++){
        let ioe = cost[i];

        for(var j = i+1; j < gas.length; j++){
            if(ioe - cost[j] > 0){
                ioe = ioe + gas[j] - cost[j]
            }else {
                return -1
            }
        }

        for(var k = 0; k <= i; k++){
            if(ioe - cost[k] > 0){
                ioe = ioe + gas[k] - cost[k]
            }else {
                return -1
            }
        }

        if(ieo >=0 ){
            return i
        }

    }    

}

const gas = [1,2,3,4,5];
const cost = [3,4,5,1,2];

























